#include "dialog.h"
#include "ui_dialog.h"
#include "emojiplus.h"
QString facename[107]={"[呲牙]", "[调皮]","[流汗]",  "[偷笑]",  "[再见]",  "[敲打]","[擦汗]",  "[猪头]","[玫瑰]","[流泪]",//0~9
                       "[大哭]", "[嘘]",  "[酷]",    "[抓狂]",  "[委屈]",  "[便便]","[炸弹]",  "[菜刀]","[可爱]","[色]",  "[害羞]",//10~20
                       "[得意]", "[吐]",  "[微笑]",  "[发怒]",  "[尴尬]",  "[惊恐]","[冷汗]",  "[爱心]","[示爱]","[白眼]"  ,//21~30
                       "[傲慢]", "[难过]","[惊讶]",  "[疑问]",  "[睡]",    "[亲亲]","[憨笑]",  "[爱情]","[衰]",  "[撇嘴]","[阴险]",//31~41
                       "[奋斗]", "[发呆]","[右哼哼]","[拥抱]",  "[坏笑]",  "[飞吻]","[鄙视]",  "[晕]",  "[大兵]","[可怜]",//42~51
                       "[强]",   "[弱]",  "[握手]",  "[胜利]",  "[抱拳]",  "[凋谢]","[饭]",    "[蛋糕]","[西瓜]","[啤酒]", "[飘虫]",//52`62
                       "[勾引]", "[OK]",  "[爱你]",  "[咖啡]",  "[钱]",    "[月亮]","[美女]",  "[刀]",  "[发抖]","[差劲]","[拳头]",//63~73
                       "[心碎]", "[太阳]","[礼物]",  "[足球]",  "[骷髅]",  "[挥手]","[闪电]",  "[饥饿]","[困]",  "[咒骂]",//74~83
                       "[折磨]", "[抠鼻]","[鼓掌]",  "[糗大了]","[左哼哼]","[哈欠]","[快哭了]","[吓]",  "[篮球]","[乒乓球]",//84~89
                       "[NO]",   "[跳跳]","[怄火]",  "[转圈]",  "[磕头]",  "[回头]","[跳绳]",  "[激动]","[街舞]","[献吻]","[左太极]",//90~99
                       "[右太极]","[闭嘴]"};

//QTextBrowser * _allContents;
Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{


//排布表情选择界面
//  expression = false;//触发表情选择窗口时，*******************
 // expressionDlg = new QDialog(this);//表情窗口
    ui->setupUi(this);
    int z=0;
    int h=20;
    int w=20;
    for(int i=0;i<8;i++)
    {
        SXQLabel *SXlabel;
        for(int j=0;j<14;j++)
        {
            if(z<=106)
                SXlabel=new SXQLabel(facename[z],this);//新建含表情方格
            else {
                SXlabel=new SXQLabel(this);//新建空白方格
                 }
            //信号发送这 发送的信号  信号接收者 处理的槽函数
            QObject::connect(SXlabel,SIGNAL(seleface2(QString)),this, SLOT(clicked(QString)));//SXlbel发送一个信号seleface2  →  由clicked发送出newsignal给chatwindow

            QString strpath;
            strpath="://face/"+QString::number(z,10)+".bmp";

            QImage iconFile(strpath);
            SXlabel->setPixmap(QPixmap::fromImage(iconFile));
            SXlabel->setGeometry(w*j+10,h*i-20,h,w);
            SXlabel->setScaledContents(true);
            z++;

        }
    }
    //设置表情选择框的属性
    this->setWindowFlags(Qt::FramelessWindowHint);//设置对话框属性
    this->setGeometry(0,0,300,140);//表情选择界面参数设置
    this->setStyleSheet("background-color:white; border: 2px solid rgb(211,228,240);");
    this->hide();


}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::clicked(QString name)
{
    emit newsignal(name);
    qDebug("fashe");
}
//点击“emoji”按钮出现的信号
//void Dialog::on_pushButton_clicked()//*************************************************
//{

//    if(expression==false)//如果处于未打开表情窗口时，点击一个表情按钮会显示表情窗口，并使expression=true为打开状态
//    {
//        // QPoint pp =ui->face_pushButton->mapToGlobal(ui->face_pushButton->pos());
//        expressionDlg->move(2,70);//移动表情选择界面在整个页面的位置
//        expressionDlg->show();//展示出表情选择按钮
//        expression = true;//************
//    }
//    else//如果处于打开表情窗口状态时，点击表情按钮，则会关闭表情窗口，并改为关闭状态
//    {
//        expressionDlg->hide();
//        expression = false;
//    }
//}




//    int num = 0;
//    for(int i=0;i<=108;i++)
//    {
//        if(facename[i] == name)
//        {
//            num = i;
//            break;
//        }
//    }
//    QString strpath;//路径的字符串
//    strpath = "<img src='://face/"+QString::number(num,10)+".bmp'/>";
//   imgPathToHtml(strpath);
//   m_TextBrowser->insertHtml(imgPath);

//    if(expression==false)
//    {
//        expressionDlg->hide();
//        expression = true;
//    }
//    else
//    {
//        expressionDlg->hide();
//        expression = false;
//    }
//}

//按下"发送"后，将消息显示在对话栏，并将输入栏清空*************************************************
//void Dialog::on_pushButton_2_clicked()
//{
//    while(!expressionQueue.empty())
//    {
//        //

//        QTextCursor temp = expressionQueue.front();//返回当前队列的第一个元素
//        expressionQueue.pop();//从当前队列里移出第一个元素
//        const  QString ass = QstringQueue.front();
//        temp.insertText(ass);
//        temp.deleteChar();//删除当前光标的
//        QstringQueue.pop();
//    }

//    QString getMsgText;

//    getMsgText =ui->textEdit_2->toPlainText();

//    ui->textEdit_2->clear(); //把textEdit控件清屏
//    ui->textEdit->append(getMsgText);//显示在上面对话框


//}
